<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

class Store extends Model
{
    use HasFactory, SoftDeletes;

    protected $fillable = [
        'name', 'short_name', 'telephone', 'phone', 'address', 'lng', 'lat', 'is_online', 'is_open',
        'leshua_num'
    ];

    public function users()
    {
        return $this->hasMany(User::class);
    }

    public function costRules()
    {
        return $this->hasMany(CostRule::class);
    }

    public function tableTypes()
    {
        return $this->hasMany(TableType::class);
    }

    public function orders()
    {
        return $this->hasMany(Order::class);
    }

    public static function getOnlineStore() : Store
    {
        return Store::findOrFail(1);
    }
}
